package com.wf.classRoomTest;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author mpk
 * @since 2024/6/3 15:30:42
 */
public class HashMapTest {

    public static void main(String[] args) {


        HashMap<String, String> map = new HashMap<>();

        map.put("1", "张三");
        map.put("1", "李四");
        map.put("2", "王五");
        map.put("3", "AA");


        Set<String> strings = map.keySet();
        System.out.println("------------KEYSET遍历--------------------");
        for (String s : strings) {

            System.out.println(s + "=" + map.get(s));
        }
        strings.forEach(s -> System.out.println(s + "=" + map.get(s)));

        System.out.println("------------FOREACH遍历--------------------");

        map.forEach((key, value) -> System.out.println(key + "=" + value));

        System.out.println("------------EntrySet遍历--------------------");
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {

            System.out.println(entry.getKey() + "=" + entry.getValue());
        }
    }

}
